package com.ying.rabbitmqspringbootproducer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: ReturnConfig
 * Package: com.ying.rabbitmqspringbootproducer.config
 * Description:
 *
 * @Author 刘英杰
 * @Create 2025/7/23 16:11
 * @Version 1.0
 */

@Configuration
public class ReturnConfig {
    public static final String EXCHANGE_RETURN_NANE = "returnExchange";
    public static final String QUEUE_RETURN_NANE = "returnQueue";

    //定义交换机
    @Bean
    public Exchange returnExchange() {
        return ExchangeBuilder.directExchange(EXCHANGE_RETURN_NANE).durable(true).build();
    }

    //定义队列
    @Bean
    public Queue returnQueue() {
        return QueueBuilder.durable(QUEUE_RETURN_NANE).build();
    }

    //绑定队列到交换机
    @Bean
    public Binding bindingReturnQueue(Exchange returnExchange, Queue returnQueue) {
        return BindingBuilder.bind(returnQueue).to(returnExchange).with("debug").noargs();
    }
}
